<?php

namespace module\index\controller;

use app\Controller;
use app\model\Coupon as Model;
use app\model\UserCoupon;

class Coupon extends Controller
{
    /**
     * 列表.
     * 
     */
    public function index()
    {
        $result = Model::with('mine')->withSearch(['status', 'my'], input('get.'))->paginate([
            'list_rows'=> input('get.pageSize/d', 10),
        ]);
        return json([
            'items' => $result->items(),
            'total' => $result->total()
        ]);
    }
    /**
     * 保存.
     * 
     */
    public function save()
    {
        $model = new UserCoupon;
        $model->save($this->request->post());
        return json($model->toArray());
    }
}
